home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Shutdown FX / Shutdown FX ƒ / sfx code ƒ / sfx main.c < prev    next >
Text File  |  1993-12-14  |  3KB  |  103 lines

  1. /**********************************************************************\
  2.  
  3. File:        sfx main.c
  4.  
  5. Purpose:    This module handles the actual shutdown proc -- creating
  6.             a grafport on the screen and clearing it (dispatching
  7.             the graphic effects).
  8.             
  9.  
  10. Shutdown FX -=- graphic effects on shutdown
  11. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  12.  
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program in a file named "GNU General Public License".
  25. If not, write to the Free Software Foundation, 675 Mass Ave,
  26. Cambridge, MA 02139, USA.
  27.  
  28. \**********************************************************************/
  29.  
  30. #include "sfx main.h"
  31. #include "sfx init.h"
  32. #include "globals.h"
  33.  
  34. #define NUM_WIPES 16
  35.  
  36. void sfxMain(void)
  37. {
  38.     int                oldMenuBarHeight;
  39.     long            oldA5;
  40.     QDGlobals        qd;                /* our QD globals. */
  41.     GrafPort        gp;                /* our grafport. */
  42.     GrafPtr            savePort;
  43.     int                whichWipe;
  44.     THz                saveZone;
  45.     int                width, height;
  46.     unsigned long    temp;
  47.     
  48.     GetPort(&savePort);
  49.     oldMenuBarHeight=MBarHeight;
  50.     MBarHeight=0;
  51.     DrawMenuBar();
  52.  
  53.     /* get a value for A5, a structure that mirrors qd globals. */
  54.     oldA5 = SetA5((long)&qd.end);
  55.     InitGraf(&qd.thePort);
  56.     OpenPort(&gp);
  57.     
  58.     HideCursor();
  59.     
  60.     width=gp.portRect.right-gp.portRect.left;
  61.     height=gp.portRect.bottom-gp.portRect.top;
  62.     
  63.     GetDateTime(&temp);
  64.     whichWipe=(temp&0x7fffffff)%NUM_WIPES;
  65.     
  66.     saveZone=GetZone();
  67.     SetZone(SysZone);
  68.  
  69.     if (whichWipe==0)        SpiralGyra(&qd.black, width, height);
  70.     else if (whichWipe==1)    CircularWipe(&qd.black, width, height);
  71.     else if (whichWipe==2)    BoxInWipe(&qd.black, width, height);
  72.     else if (whichWipe==3)    Skipaline(&qd.black, width, height);
  73.     else if (whichWipe==4)    RandomWipe(&qd.black, width, height);
  74.     else if (whichWipe==5)    FullScrollUD(&gp, &qd.black, width, height);
  75.     else if (whichWipe==6)    MrDo(&gp, &qd.black, width, height);
  76.     else if (whichWipe==7)    MrDoOutdone(&gp, &qd.black, width, height);
  77.     else if (whichWipe==8)    DiagonalWipe(&qd.black, width, height);
  78.     else if (whichWipe==9)    BoxOutWipe(&qd.black, width, height);
  79.     else if (whichWipe==10)    CircleSerendipity(&qd.black, width, height);
  80.     else if (whichWipe==11)    FourCorner(&qd.black, width, height);
  81.     else if (whichWipe==12)    HalvesScroll(&gp, &qd.black, width, height);
  82.     else if (whichWipe==13)    RescueRaiders(&qd.black, width, height);
  83.     else if (whichWipe==14)    SkipalineLR(&qd.black, width, height);
  84.     else if (whichWipe==15)    SlideWipe(&gp, &qd.black, width, height);
  85.  
  86. // You would think a simple switch-case statement would suffice, but you would
  87. // be mistaken.  In fact, the analogous switch-case causes a crash on a Powerbook
  88. // 100.  This is most likely a THINK C bug; it is super-optimizing the switch-case
  89. // so much that it no longer works on a 68000 machine.  The series of if-then-elses
  90. // is less elegant to the programmer, but more elegant to the user, since it
  91. // doesn't crash.  (:
  92.  
  93.     SetZone(saveZone);
  94.     
  95.     MBarHeight=oldMenuBarHeight;
  96.     ShowCursor();
  97.     ObscureCursor();
  98.     
  99.     ClosePort(&gp);
  100.     SetA5(oldA5);
  101.     SetPort(savePort);
  102. }
  103.